package com.ftg.learn.xmlinterface.mapper;

import com.ftg.learn.xmlinterface.entity.TeacherEntity;
import com.ftg.learn.xmlinterface.vo.TeacherListVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 描述
 * 面向对象当中的一个类  {接口类}
 * 没有sql，所以我们要在mapper映射器文件里面完成sql
 *
 * @author 布衣
 * @date 2025/5/25
 */
public interface TeacherMapper {

    //    常见方法 ------------------------------》
    List<Map<String, Object>> getTeachers();

    List<TeacherEntity> getTeachersByName(String tname);

    //代码  ： jdbc
    // mybatis  :  它有一个返回值 转换逻辑
    int save(TeacherEntity teacherEntity);

    boolean update(TeacherEntity t);

    boolean deleteByTno(int tno);

    int deleteByTname(String tname);

    int delBathByTnos(List<String> tnos);

//    常见方法 ------------------------------》

    //    特殊的方法
    List<TeacherEntity> getTeachersByNames(TeacherEntity t);

    List<TeacherListVo> leftSel();
    /**
     * update where tno = ? delete where tno=?
     * 按名称做模糊查询
     *
     * select * from teacher where tname like '%张%';  [动态sql]
     */
    //注解
    @Select("<script>select * from teacher " +
            "<where>"+
            "<if test=\"tname != null\">"+
            "tname like concat(#{tname},'%')"+
            "</if>"+
            "</where>"+
            "</script>")
    List<TeacherEntity> showTeacherByName(@Param("tname")String tname);
}
